<?php
namespace App\Http\Controllers\OgreenCard;
use App\Http\Controllers\Controller;

class BaseController extends Controller
{

    public static function get_empty_arr($keys){

        if(gettype($keys) == gettype("a"))
        {
            $keys = explode(",",$keys);
        }

        $arr = [];
        foreach($keys as $key)
        {
            $arr[$key] = "";
        }

        return $arr;
    }

    public static function date_time($time=0){
        if($time == 0){
            $time = time();
        }
        return date('Y-m-d H:i:s',$time);
    }

    public static function response($data = []){
        if(is_string($data)){
            $data = ["code"=>2001,"msg"=>$data];
        }elseif(is_array($data)){
            if(!isset($data['code'])) $data['code'] = 200;
            if(!isset($data['msg'])) $data['msg'] = "SUCCESS";
        }
        return response($data);
    }

    public static function view($view,array $data=[]){
        return view("ogreencard.".$view,$data);
    }

    public static $orderTypes = ["wx"=>"微信",'sg'=>"手工","pos"=>"POS机"];
    public static $orderCardTypes = ["sc"=>"食材卡",'gwk'=>"购物卡",'pos'=>'POS机','ps'=>'拍照服务'];
}